import http from "@/utils/http";
import { AxiosRequestConfig } from "axios";

export interface DeleteMetricsBatchDelete_ {
  /**
   * @description 指标id列表
   */
  ids?: number[];
}
export interface PutMetricsBatchPublish_ {
  /**
   * @description ids
   */
  ids: number[];
  /**
   * @description opType
   * @format int32
   */
  opType: number;
}
export interface GetMetricsDictionaryApplicationById_ {
  /**
   * @description 应用id
   * @format int32
   * @example 1
   */
  appId?: number;
  /**
   * @description 指标id
   * @format int32
   * @example 1
   */
  id?: number;
}
export interface GetMetricsGetDerivedOfMetricsById_ {
  /**
   * @description id
   */
  id: number;
}
export interface GetMetricsGetDevelopMetricsList_ {
  /**
   * @description cnName
   */
  cnName?: string;
}
export interface GetMetricsHintSimpleList_ {
  /**
   * @description 指标内容。包含中文名、英文名、id、别名
   */
  content?: string;
  /**
   * @description 页数
   * @format int32
   */
  pageNum?: number;
  /**
   * @description 条数
   * @format int32
   */
  pageSize?: number;
  /**
   * @description 0-所有, 5-已发布
   * @format int32
   */
  reviewStatusCode?: number;
  /**
   * @description 主题id
   * @format int32
   */
  subjectId?: number;
  /**
   * @description 指标类型。1：原子指标:，2：派生指标，3：衍生指标
   */
  types?: number[];
}
export interface GetMetricsList_ {
  /**
   * @description 默认聚合方式
   * @format int32
   */
  aggregation?: number;
  /**
   * @description 授权人
   */
  authorizer?: string;
  /**
   * @description 业务负责人
   */
  businessOwner?: string;
  /**
   * @description 中文名称
   */
  cnName?: string;
  /**
   * @description 指标内容。包含中文名、英文名、id、别名
   */
  content?: string;
  /**
   * @description 创建人
   */
  createBy?: string;
  /**
   * @description 创建时间
   */
  createTime?: string[];
  /**
   * @description 数据类型
   * @format int32
   */
  dataType?: number;
  /**
   * @description 部门id
   * @format int32
   */
  departmentId?: number;
  /**
   * @description 指标等级的字典值id
   * @format int32
   */
  gradeId?: number;
  /**
   * @description groupId
   * @format int32
   */
  groupId?: number;
  /**
   * @description 我的创建标识
   */
  myCreate?: boolean;
  /**
   * @description 排序顺序,可选的值1:asc:、2:desc，默认2。
   * @format int32
   */
  order?: number;
  /**
   * @description 页数
   * @format int32
   */
  pageNum?: number;
  /**
   * @description 条数
   * @format int32
   */
  pageSize?: number;
  /**
   * @description 指标审核状态的数字编号呈现。1：草稿，2：创建审核中，3：未发布，4：发布审核中，5：已发布
   * @format int32
   */
  reviewStatus?: number;
  /**
   * @description rootId
   * @format int32
   */
  rootId?: number;
  /**
   * @description 排序条件,可选的值cnName、id、createBy、reviewStatus、pageviewCount、type,默认cnName
   */
  sortBy?: string;
  /**
   * @description 主题id
   * @format int32
   */
  subjectId?: number;
  /**
   * @description 支持的维度
   */
  supportDemension?: number[];
  /**
   * @description 技术负责人
   */
  techOwner?: string;
  /**
   * @description 支持的统计粒度
   */
  timePeriod?: number[];
  /**
   * @description 指标类型。1：原子指标:，2：派生指标，3：衍生指标
   * @format int32
   */
  type?: 1 | 2 | 3;
  /**
   * @description 更新人
   */
  updateBy?: string;
  /**
   * @description 更新时间
   */
  updateTime?: string[];
}
export interface PutMetricsPublishById_ {
  /**
   * @description 操作类型：1-发布,2-下线
   * @format int32
   * @example 1
   */
  opType?: number;
  /**
   * @description id
   * @format int32
   */
  id: number;
}
export interface GetMetricsUndevelopStatusMetrics_ {
  /**
   * @description cnName
   */
  cnName?: string;
  /**
   * @description subjectId
   * @format int32
   */
  subjectId?: number;
}
export interface GetMetricsById_ {
  /**
   * @description 浏览方式。1：指标管理，不会记录浏览。2：指标市场, 会记录浏览
   * @format int32
   * @example 1
   */
  viewWay?: number;
  /**
   * @description 指标id
   * @format int32
   * @example 1
   */
  id: number;
}
export interface DeleteMetricsById_ {
  /**
   * @description 指标id
   */
  id: number;
}

export class Metrics {
  /**
   * 指标管理页新增指标
   *
   * @tags 指标操作
   * @request POST: /metrics
   * @secure
   */
  postMetrics = (metricDTO: defs.NewMetricsDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityNewMetricsVO>({
      url: `/metrics`,
      method: "POST",
      data: metricDTO,
      ...params,
    });

  /**
   * 指标管理页编辑指标
   *
   * @tags 指标操作
   * @request PUT: /metrics
   * @secure
   */
  putMetrics = (metricDTO: defs.NewMetricsDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityNewMetricsVO>({
      url: `/metrics`,
      method: "PUT",
      data: metricDTO,
      ...params,
    });

  /**
   * 指标批量删除
   *
   * @tags 指标操作
   * @request DELETE: /metrics/batch-delete
   * @secure
   */
  deleteMetricsBatchDelete = (query: { ids?: number[] } | DeleteMetricsBatchDelete_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntity>({
      url: `/metrics/batch-delete`,
      method: "DELETE",
      params: query,
      ...params,
    });

  /**
   * 指标批量发布或下线
   *
   * @tags 指标操作
   * @request PUT: /metrics/batch-publish
   * @secure
   */
  putMetricsBatchPublish = (
    query: { ids: number[]; opType: number } | PutMetricsBatchPublish_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntity>({
      url: `/metrics/batch-publish`,
      method: "PUT",
      params: query,
      ...params,
    });

  /**
   * 指标库指标详情页应用信息展现
   *
   * @tags 指标操作
   * @request GET: /metrics/dictionary-application/{id}
   * @secure
   */
  getMetricsDictionaryApplicationById = (
    { id, ...query }: { appId?: number; id?: number } | GetMetricsDictionaryApplicationById_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityListReportInfo>({
      url: `/metrics/dictionary-application/${id}`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 获取衍生指标下定义的指标列表
   *
   * @tags 指标操作
   * @request GET: /metrics/getDerivedOfMetrics/{id}
   * @secure
   */
  getMetricsGetDerivedOfMetricsById = (
    { id }: { id: number } | GetMetricsGetDerivedOfMetricsById_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityListNewMetricsVO>({
      url: `/metrics/getDerivedOfMetrics/${id}`,
      method: "GET",
      ...params,
    });

  /**
   * 已开发指标列表(原子指标、派生指标)
   *
   * @tags 指标操作
   * @request GET: /metrics/getDevelopMetricsList
   * @secure
   */
  getMetricsGetDevelopMetricsList = (
    query: { cnName?: string } | GetMetricsGetDevelopMetricsList_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityListNewMetricsVO>({
      url: `/metrics/getDevelopMetricsList`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 按模糊的指标内容等条件查询已发布状态的指标的简要信息列表。可用于指标管理创建派生指标时查询原子指标
   *
   * @tags 指标操作
   * @request GET: /metrics/hint-simple-list
   * @secure
   */
  getMetricsHintSimpleList = (
    query:
      | {
          content?: string;
          pageNum?: number;
          pageSize?: number;
          reviewStatusCode?: number;
          subjectId?: number;
          types?: number[];
        }
      | GetMetricsHintSimpleList_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityPageInfoNewSimpleMetricsVO>({
      url: `/metrics/hint-simple-list`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 多条件搜索出指标列表。用于指标管理-指标列表和指标库-指标列表
   *
   * @tags 指标操作
   * @request GET: /metrics/list
   * @secure
   */
  getMetricsList = (
    query:
      | {
          aggregation?: number;
          authorizer?: string;
          businessOwner?: string;
          cnName?: string;
          content?: string;
          createBy?: string;
          createTime?: string[];
          dataType?: number;
          departmentId?: number;
          gradeId?: number;
          groupId?: number;
          myCreate?: boolean;
          order?: number;
          pageNum?: number;
          pageSize?: number;
          reviewStatus?: number;
          rootId?: number;
          sortBy?: string;
          subjectId?: number;
          supportDemension?: number[];
          techOwner?: string;
          timePeriod?: number[];
          type?: 1 | 2 | 3;
          updateBy?: string;
          updateTime?: string[];
        }
      | GetMetricsList_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityPageInfoNewMetricsVO>({
      url: `/metrics/list`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 指标发布或下线
   *
   * @tags 指标操作
   * @request PUT: /metrics/publish/{id}
   * @secure
   */
  putMetricsPublishById = (
    { id, ...query }: { opType?: number; id: number } | PutMetricsPublishById_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityNewMetricsVO>({
      url: `/metrics/publish/${id}`,
      method: "PUT",
      params: query,
      ...params,
    });

  /**
   * 获取未加工指标
   *
   * @tags 指标操作
   * @request GET: /metrics/undevelop_status_metrics
   * @secure
   */
  getMetricsUndevelop_status_metrics = (
    query: { cnName?: string; subjectId?: number } | GetMetricsUndevelopStatusMetrics_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityListOptionVO>({
      url: `/metrics/undevelop_status_metrics`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 根据id获取指标详情。用于指标管理-编辑指标回显，指标管理-查看指标详情，指标市场-指标详情
   *
   * @tags 指标操作
   * @request GET: /metrics/{id}
   * @secure
   */
  getMetricsById = (
    { id, ...query }: { viewWay?: number; id: number } | GetMetricsById_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityNewMetricsVO>({
      url: `/metrics/${id}`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 指标管理页删除指标
   *
   * @tags 指标操作
   * @request DELETE: /metrics/{id}
   * @secure
   */
  deleteMetricsById = ({ id }: { id: number } | DeleteMetricsById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityBoolean>({
      url: `/metrics/${id}`,
      method: "DELETE",
      ...params,
    });
}

export default new Metrics();
